home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
telecomm
/
sticpsrc.lzh
/
SOURCE.ARC
/
ATARI.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-06
|
63KB
|
2,377 lines
/*
* Atari ST-specific functions
* written by Rob Janssen, PE1CHL
* 3 configurations are possible:
* .TOS
* .ACC define GEM and GEMACC
* .PRG define GEM and GEMPRG
*/
#include <stdio.h>
#include <ctype.h>
#ifdef MWC
# include <osbind.h> /* os interface defines */
# define Kbshift Getshift /* MW goofed... */
#endif
#ifdef __TURBOC__
# define cdecl
# include <tos.h> /* os interface defines */
#endif
#include <linea.h> /* line-A interface defines */
#include <time.h>
#ifdef __TURBOC__ /* line-A access for Turbo C */
# define VPLANES Linea->v_planes
# define V_CEL_HT Vdiesc->v_cel_ht
# define V_CEL_MX Vdiesc->v_cel_mx
# define V_CEL_MY Vdiesc->v_cel_my
# define V_CUR_AD ((char *) (Vdiesc->v_cur_ad))
# define V_CUR_OFF Vdiesc->v_cur_off
# define V_CUR_CX Vdiesc->v_cur_xy[0]
# define V_CUR_CY Vdiesc->v_cur_xy[1]
# define V_FNT_AD ((char *) (Vdiesc->v_fnt_ad))
#endif
#include "global.h"
#include "config.h"
#include "mbuf.h"
#include "internet.h"
#include "iface.h"
#include "atari.h"
#include "timer.h"
#include "environ.h"
extern unsigned nasy;
/* Interface list header */
struct interface *ifaces;
#ifdef OUTBUF
static char *ttbuf;
#endif
int auxcon = 0; /* auxcon control word */
#define AUXCOUT 0x01 /* send out to AUX */
#define AUXCNOT 0x02 /* don't send out to screen */
#define AUXCIN 0x10 /* read input from AUX */
int auxitrn[256]; /* aux input translate table */
char auxotrn[256]; /* aux output translate table */
int screenmode = 0; /* screen output control word */
#define SCRTOS 0 /* output via TOS */
#define SCRBIOS 1 /* output via BIOS */
#define SCRDIR 2 /* direct output to screen */
extern void trap_x(); /* handler for trap #5/#11 */
void (*trap_x_save)(); /* saved trap #5/#11 handler */
extern char startup[]; /* startup file name */
extern FILE *logfp; /* log file pointer */
extern char logname[]; /* log file name */
extern FILE *trfp; /* trace file pointer */
extern char trname[]; /* trace file name */
#ifdef GEM
#define WORD int /* signed word (16 bits) */
#define TRUE (1) /* TRUE value */
#define FALSE (0) /* FALSE value */
#include <gemdefs.h> /* MW GEM definitions */
#include <obdefs.h>
#define MAXWIN 8 /* maximal window handle from GEM */
#define USEWIN 2 /* windows used by this application */
#define DESK 0 /* window number for desktop */
#define ALIGN(x,n) (x) = (n * (((x) + (n / 2)) / n))/* align x to n incr. */
#define WI_KIND (HSLIDE|RTARROW|LFARROW|VSLIDE|DNARROW|UPARROW|SIZER|MOVER|FULLER|CLOSER|NAME)
#define MIN_WIDTH (16 * gr_hwbox) /* minimal window width */
#define MIN_HEIGHT (5 * gr_hhbox) /* minimal window height */
#define MAXLINE 100 /* history lines saved */
#define MAXCHAR 80 /* max characters on each line */
/*** datatypes ***/
typedef struct linehist /* define 'line history' type */
{
struct linehist *next; /* forward link */
struct linehist *prev; /* backward link */
int len; /* this one's length */
char line[1]; /* the actual line to be stored */
} LINEHIST;
typedef struct /* define 'sliding window' type */
{
long total; /* total size in this dimension */
long pos; /* pos of portion currently seen */
int seen; /* size of portion currently seen */
} SLWIN;
typedef struct window /* info about windows */
{
WORD win; /* corresponding window handle */
WORD kind; /* this window's wi_kind */
WORD pobj; /* object selected there */
GRECT work; /* work area pos/size */
GRECT full; /* full size of window */
GRECT org; /* originating pos/size for shrink */
SLWIN hori; /* horizontal slider info */
SLWIN vert; /* vertical slider info */
LINEHIST *head; /* head of line history */
LINEHIST *tail; /* tail of line history */
int curpos; /* position on current line */
char curline[MAXCHAR + 1]; /* current line */
char cursor; /* cursor state */
char open; /* window opened? */
char title[MAX_LEN]; /* window title (if any) */
char info[MAX_LEN]; /* window info (if any) */
} WINDOW;
/*** GLOBAL VARIABLES ***/
/* GEM handles, information and the like */
extern WORD gl_apid; /* application id (external to MWC) */
WORD gl_mnid; /* menu id for this accessory */
WORD gr_handle; /* physical workstation handle */
static WORD handle; /* virtual workstation handle */
WORD gr_hhchar,gr_hwchar,gr_hhbox,gr_hwbox;/* system font sizes */
/* window management datastructures */
static WINDOW window[USEWIN]; /* window info, DESK + user windows */
static WORD win[MAXWIN]; /* handle to application conv. */
static WORD topwin = -1; /* top (=current) window handle */
static WORD await = MU_MESAG|MU_TIMER; /* select initially active events */
static GRECT m1,m2; /* mouse event rectangles */
static WORD m1flag,m2flag; /* flags for mouse events 1,2 */
static WORD keyqueue = 0; /* last typed character */
static WORD keyqstat = 0; /* it's shift status */
static WORD fastpoll = 50; /* fast poll interval */
WORD work_in[] = {1,1,1,1,1,1,1,1,1,1,2};/* Input to GSX parameter array */
WORD work_out[57]; /* Output from GSX parameter array */
WORD contrl[12]; /* storage wasted for bindings */
WORD intin[128];
WORD ptsin[128];
WORD intout[128];
WORD ptsout[128];
/* the resource file symbols */
#ifdef GEMPRG
# include "atari_rs.h"
extern OBJECT *rs_trindex[];
#endif
/* forward declarations (when necessary) */
void pop_up();
void wi_getwork();
void wi_close();
void sl_update();
void rq_redraw();
WORD do_form();
WORD *rc2pts();
int wputc();
#else /* not GEM */
# define CONTERM *((char *) 0x484L) /* system's conterm byte */
char sconterm; /* saved conterm byte */
char *logbase; /* logical screen base */
int cursor = 1; /* cursor currently visible? */
# ifdef MWC
extern int _fputt(); /* standard output putc routine */
# endif
#endif
#ifndef GEMACC
# ifdef MWC
long *_stksize = (long *) 4096; /* stack size in bytes, becomes ptr */
# define STACK _stksize
# endif
# ifdef __TURBOC__
extern long *_StkLim; /* initialized to stack limit */
# define STACK _StkLim
# endif
# define STKMAGIC 0x31415927L /* magic to check overflow */
#endif
void eihalt();
#ifndef GEMACC
#ifdef __TURBOC__
static void watchtick(void,...); /* function called at timer tick */
static void (*orgtick)(void,...); /* original timertick handler */
#else
static void watchtick(); /* function called at timer tick */
static void (*orgtick)(); /* original timertick handler */
#endif
static long watchcnt; /* actual watchdog counter */
static long watchnet; /* watchdog while in NET */
static long watchsh; /* watchdog while in SHELL */
static unsigned watchhw; /* watchdog hardware reset */
#endif
static void lat_start(),lat_stop(),lat_raw(),lat_status();
/* Called at startup time to set up console I/O, memory heap */
/* also sets and saves lots of other things on the Atari.... */
ioinit()
{
#ifdef GEM
WORD d;
# ifdef GEMACC
char net[30];
# endif
#else
long sav_ssp; /* saved stackpointer for Super() */
#endif
#if (defined(MWC) && (MWC < 300)) /* pre-3.0 MW C? */
/* set the handler for trap #5. this will be called using the */
/* micro_rtx() function, and will disable/enable interrupts */
trap_x_save = (void (*)()) Setexc(0x25,trap_x);
#else
/* set the handler for trap #7. this will be called using the */
/* _VtrapB_() function, and will disable/enable interrupts */
trap_x_save = (void (*)()) Setexc(0x27,trap_x);
#endif
#ifndef GEMACC
STACK[0] = STACK[16] = /* mark stack for overflow check */
STACK[32] = STKMAGIC;
orgtick = (void (*)()) Setexc(0x100,watchtick); /* install watchdog ticker */
#endif
#if (OUTBUF && !GEM)
ttbuf = malloc(BUFSIZ);
setbuf(stdout,ttbuf);
#endif
#ifdef GEM
/* re-route output from "stdout" to window handler */
stdout->_pt = wputc; /* character output handler */
stdout->_ff |= _FERR;